
package edu.tongji.jiaowu.dao.jdbc;
 
import java.util.List;

import edu.tongji.jiaowu.dao.GraduateDao;
import com.tongji.quickCRUDQ.define.Row;
import com.tongji.quickCRUDQ.model.CommonBean;
import com.tongji.quickCRUDQ.dao.jdbc.BaseDaoJdbc;

public class GraduateDaoJdbc extends BaseDaoJdbc implements GraduateDao {
	String tableName="T_GRADUATE";
	String beanName="graduate";
	
	public CommonBean createGraduate(){
		CommonBean graduates=this.createBean(tableName,beanName);
                return graduates;		
	}
	
/*
	public CommonBean findGraduates(String refid) {
		CommonBean graduates=this.createGraduate();
		String sql="select * from T_GRADUATE where refid=?";
		List data=this.getCommonDao().select(sql,new String[]{refid});
		graduates.addData(data);
                return graduates;
       }
*/
	public CommonBean findGraduateById(String id) {
		CommonBean graduates=this.createGraduate();
		String sql="select * from T_GRADUATE where id=?";
		List data=this.getCommonDao().select(sql,new String[]{id});
		graduates.addData(data);
    return graduates;
  }
  
	public CommonBean findAllGraduates() {
		CommonBean graduates=this.createGraduate();
		String sql="select * from T_GRADUATE ";
		List data=this.getCommonDao().select(sql,new String[]{});
		graduates.addData(data);
    return graduates;
  }
	public void insertGraduate(CommonBean graduateBean){
		List data=graduateBean.getData();
		Row row=this.getRow(tableName);
		this.getCommonDao().templateBatchInsert(row,data,this.getIdGenerator());
	}
	public void updateGraduate(CommonBean graduateBean){
		List data=graduateBean.getData();
		Row row=this.getRow(tableName);
		this.getCommonDao().templateBatchUpdate(row,data);
	}

	public void check(String graduateYear) {
		getCommonDao().callProcedure("p_graduate", new int[]{1},new String[]{graduateYear});
	}

	public String count(String year) {
		String sql="select count(*) from t_graduate where graduate_year=?";
		return getCommonDao().getString(sql,new String[]{year});
	}

	public List findGraduateYears() {
		String sql="SELECT distinct graduate_year from t_graduate  order by graduate_year";
		List data= this.getCommonDao().selectOneFieldList(sql,new String[]{});
		return data;
	}
}

